unit Cons_Turno;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids,
  TFlatButtonUnit;

type
  TFrmCons_Turno = class(TFrmConsulta)
    DBGrid: TDBGrid;
    Label1: TLabel;
    ed_descricao: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure BtnFecharClick(Sender: TObject);
    procedure ed_descricaoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    procedure Faz_Consulta;
  public
    { Public declarations }
  end;

var
  FrmCons_Turno: TFrmCons_Turno;
  xcons_turno: string;

implementation

uses clsTurno, dm, dbtables, db;

var
  turno: TTurno;
  tq: TQuery;
  tds: TDataSource;

{$R *.DFM}

  { TFrmCons_Turno }

procedure TFrmCons_Turno.Faz_Consulta;
begin
  turno.Consultar(ed_descricao.text, tq);
end;

procedure TFrmCons_Turno.FormCreate(Sender: TObject);
begin
  inherited;
  turno := TTurno.Create;
  tq := TQuery.Create(self);
  tds := TDataSource.Create(self);
  tq.databasename := dmint.db.databasename;
  tq.active := false;
  tds.DataSet := tq;
  dbgrid.DataSource := tds;
end;

procedure TFrmCons_Turno.FormDestroy(Sender: TObject);
begin
  inherited;
  turno.free;
  tq.free;
  tds.free;
end;

procedure TFrmCons_Turno.FormActivate(Sender: TObject);
begin
  inherited;
  Faz_Consulta;
end;

procedure TFrmCons_Turno.BtnFecharClick(Sender: TObject);
begin
  xcons_turno := tq.fieldbyname('Cod_Turno').asstring;
  inherited;
end;

procedure TFrmCons_Turno.ed_descricaoKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key = 12 then Faz_Consulta;
end;

end.
